package com.atcumt.alibaba;

import java.util.Scanner;

public class WZ02 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        while (n-- > 0) {
            long a = in.nextLong();
            long b = in.nextLong();
            if (a > b) {
                long solveTemp = solve(a, b);
                if (solveTemp != -1) {
                    long out = (solveTemp / 3) + (solveTemp % 3) / 2 + (solveTemp % 3) % 2;
                    System.out.println(out);
                } else {
                    System.out.println(-1);
                }
            } else {
                long solveTemp2 = solve2(a, b);
                if (solveTemp2 != -1) {
                    long out = (solveTemp2 / 3) + (solveTemp2 % 3) / 2 + (solveTemp2 % 3) % 2;
                    System.out.println(out);
                } else {
                    System.out.println(-1);
                }
            }
        }
        in.close();
    }

    private static long solve2(long a, long b) {
        long count = 0;
        while (a < b) {
            a *= 2;
            count++;
        }
        if (a == b) {
            return count;
        } else {
            return -1;
        }
    }

    private static long solve(long a, long b) {
        long count = 0;
        while (a < b) {
            a /= 2;
            count++;
        }
        if (a == b) {
            return count;
        } else {
            return -1;
        }
    }
}
